import requests

baidu_url = 'https://fanyi.baidu.com/sug'

while True:
    src_text = input('请输入单词（中文或英文）').strip()
    if src_text.lower()=='q':
        break

    data = {'kw':src_text}
    resp = requests.post(baidu_url, data)
    if resp.status_code==200:
        res_data = resp.json()
        if res_data['errno']==0:
            for kv in res_data['data']:
                if kv['k']==src_text:
                    print(kv['v'])
                    break
            else:
                print('没有找到！')
        else:
            print(res_data)
    else:
        print(resp.content)